package com.wuzheng.wisgo.sanitation.cloud.controller.vehicle;


import com.wuzheng.wisgo.sanitation.cloud.model.locate.param.PositionParam;
import com.wuzheng.wisgo.sanitation.cloud.model.locate.param.PositionVehicleParam;
import com.wuzheng.wisgo.sanitation.cloud.model.locate.pojo.PositionListDto;
import com.wuzheng.wisgo.sanitation.cloud.model.locate.pojo.PositionVehicleDto;
import com.wuzheng.wisgo.sanitation.framework.base.annotation.Authorization;
import com.wuzheng.wisgo.sanitation.framework.core.constant.SysRespEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.wuzheng.wisgo.sanitation.framework.core.protocol.Result;
import com.wuzheng.wisgo.sanitation.cloud.service.locate.ReceiveInfoNewService;


import org.springframework.web.bind.annotation.RestController;
import com.wuzheng.wisgo.sanitation.framework.base.controller.BaseController;

/**
 * @author：hibon
 * @date：Created in 2019-10-09
 * @description：地图定位接口
 * @modified By：
 * @version: 1.0
 */
@RestController
@RequestMapping("/locate")
@Api(value = "LocateCtrl", tags = "地图定位接口")
public class LocateCtrl extends BaseController {

    @Autowired
    private ReceiveInfoNewService receiveInfoNewService;

    /**
     * 获取地图上所有车辆定位点
     */
    @PostMapping(value = "/list")
    @ApiOperation(value = "获取地图上所有车辆定位点")
    public Result<PositionListDto> list(
            @RequestBody @Validated PositionParam positionParam,
            BindingResult bindingResult) throws BindException {
        if (bindingResult.hasErrors()) {
            throw new BindException(bindingResult);
        }
        return this.success(SysRespEnum.SUCCESS.getMessage(), receiveInfoNewService.selectPositionVoList(positionParam));
    }

    /**
     * 获取定位车辆信息
     */
    @Authorization
    @PostMapping(value = "/getVehicleInfo")
    @ApiOperation(value = "获取定位车辆信息")
    public Result<PositionVehicleDto> get(
            @RequestBody @Validated PositionVehicleParam positionVehicleParam,
            BindingResult bindingResult) throws BindException {
        if (bindingResult.hasErrors()) {
            throw new BindException(bindingResult);
        }
        return this.success(SysRespEnum.SUCCESS.getMessage(), receiveInfoNewService.selectPositionVehicleVoInfo(positionVehicleParam));
    }
}

